<?php

/**
 * Load the classes
 */
function __autoload($class_name) {
	$class_name = str_replace('\\', DIRECTORY_SEPARATOR, $class_name);

	require_once("{$class_name}.php");
}

date_default_timezone_set('UTC');

use Theatre\Dispatcher;

class Theatre {
	static function run() {
		$config = array(
			'docRoot'    => dirname(__FILE__),
			'namespace'  => 'Theatre\\Server',
			'useSSL'     => false,
			'serverHost' => 'theatre.local',
			'useSession' => false,
			'sessionKey' => 'theatre_user',
			'db'         => array(
				'driver'     => 'postgres',
				'persistent' => false,
				'host'       => 'localhost',
				'login'      => 'theatre_server',
				'password'   => 'theatre_server',
				'database'   => 'theatre_server',
				'encoding'   => 'utf8'
			)
		);

		try {
			new Theatre\Dispatcher($config);
		}
		catch (\Exception $e) {
			print 'Server error';
		}
	}
}
